package com.ocom.accesservice.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.accesservice.dao.IDaoCompanyKeyInfo;
import com.ocom.accesservice.service.CompanyKeyInfoService;
import com.ocom.common.entity.master.EntityCompanykeyInfo;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import org.springframework.stereotype.Service;


@Service
public class CompanyKeyInfoServiceImpl extends ServiceImpl<IDaoCompanyKeyInfo, EntityCompanykeyInfo> implements CompanyKeyInfoService {

    @Override
    @DataSourceAspect(type= DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    public EntityCompanykeyInfo getCompanyKeyInfo(Long companyId){
        QueryWrapper<EntityCompanykeyInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("com_id",companyId);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }


}
